﻿using Architecture.Api.Application.Commands.SupplierCommand;
using Architecture.Domain.Services.Interface;
using Architecture.Domain.TraceabilityManage;
using AutoMapper;
using MediatR;

namespace Architecture.Api.Application.CommandHandlers.SupplierHandler
{
    public class SupplierBatchCommandHandler : IRequestHandler<SupplierBatchCommand, int>
    {
        private readonly IDeepProcessingService _deepProcessingservice;
        private readonly IMapper _mapper;

        public SupplierBatchCommandHandler(IDeepProcessingService deepProcessingservice, IMapper mapper)
        {
            _deepProcessingservice = deepProcessingservice;
            _mapper = mapper;
        }

        public async Task<int> Handle(SupplierBatchCommand request, CancellationToken cancellationToken)
        {
            Supplier supplier = _mapper.Map<Supplier>(request);
            return await _deepProcessingservice.BatchSupplier(supplier, request.flag);
        }
    }
}
